package com.system.manager.modules.risk.controller;


import com.system.manager.common.annotation.CurrSubject;
import com.system.manager.common.annotation.PreAuthorize;
import com.system.manager.common.entity.PageDTO;
import com.system.manager.common.entity.Result;
import com.system.manager.modules.authorized.entity.Subject;
import com.system.manager.modules.authorized.enums.SubjectType;
import com.system.manager.modules.risk.entity.RiskType;
import com.system.manager.modules.risk.entity.TbFileStaffstation;
import com.system.manager.modules.risk.service.ITbFileStaffstationService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author yxp
 * @since 2021-11-24
 */
@Slf4j
@Api(tags = "文件和部门人员表")
@RestController
@RequestMapping("/risk/tb-file-staffstation/")
public class TbFileStaffstationController {
    @Autowired
    private ITbFileStaffstationService iTbFileStaffstationService;
    @ApiOperation("获取所有的文件学习任务")
    @PreAuthorize({SubjectType.SYSTEM_ADMIN,SubjectType.RISK_ADMIN})
    @GetMapping("list")
    public PageDTO riskTypeList(@RequestParam(name = "page", required = false, defaultValue = "1")Integer page,
                               @RequestParam(name = "limit", required = false, defaultValue = "10")Integer size,
                               @CurrSubject Subject subject) {
            // 获取所有的风险类型
            PageDTO<TbFileStaffstation> pageDTO = iTbFileStaffstationService.selection(page, size, subject);
            return pageDTO;

    }

    /*
    修改完成状态
     */
    @ApiOperation("修改文件完成状态")
    @PreAuthorize({SubjectType.SYSTEM_ADMIN,SubjectType.RISK_ADMIN})
    @PostMapping("updateState")
    public Result updateState(Integer fileId,@CurrSubject Subject subject){
        iTbFileStaffstationService.updateState(subject, fileId);
        return Result.ok();
    }

}
